<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\admin\model;
use think\Model;
/**
 * Description of Employee
 *
 * @author HuangLuSen
 */
class Employee extends Model{
    //put your code here
    public function getIslevelTextAttr($value,$data)
    {
       $status = [1=>'普通员工',2=>'中层领导',3=>'领导',0=>'<span style="color:red;">未知</span>'];
        return $status[$data['islevel']];
    }
    public function getStateTextAttr($value,$data)
            
    {
        $status = [1=>'<span style="color:green;">启用</span>',2=>'<span style="color:red;">禁用</span>',3=>'<span style="color:red;">未知</span>'];
        return $status[$data['state']];
    }
    //关联查询
    public function department(){
//        return $this->belongsTo('Department','sid','id');
        return $this->belongsTo('department','sid','id',[],"LEFT");
    }
    //关联评估结果表
    public function subject(){
        return $this->hasOne('Subject', 'bpgrid','id',[],'LEFT')->field('bpgrid,zlyjx1,zlyjx2,tdgl1,tdgl2,tdgl3,gsjy,zpg');
    }
    //更新数据
    public function editData($data){
        $reulst=$this->validate(TRUE)->isUpdate(TRUE)->save($data);
        return $reulst;
    }
    //关联更新数据
    public function addData($data){
        $reulst=$this->validate(TRUE)->save($data);
        return $reulst;
    }
}
